using System;
using System.Web;
using System.Web.UI;
using Portal.Data.Entity;
using Portal.Data.Webparts;
using Portal.Data.Config;

public partial class Webparts_Banner_SimpleBanner : WebpartControl
{
    public override WebpartConfig NewConfig
    {
        get { return new BannerConfig(); }
    }

    protected BannerConfig PartConfig
    {
        get { return (BannerConfig) Config; }
    }

    protected override void Render(HtmlTextWriter writer)
    {
        if (HttpContext.Current.Request.Path.IndexOf("admin.aspx", StringComparison.OrdinalIgnoreCase) > 0)
            return;

        Banner b = Banner.FindByPrimaryKey(PartConfig.Banner);
        if (b == null)
        {
            return;
        }

        writer.Write("<div align='center' class='simplebanner " + Config.ClassName + "' style=\"" + PartConfig.Style + "\">");
        writer.Write(b.DisplayHtml(Config.Width, Config.Height, PartConfig.ActiveUrl, PartConfig.NewWindow));
        writer.Write("</div>");
       }
}